package com.usian.admin.controller;

import com.usian.admin.service.AdSensitiveService;
import com.usian.apis.admin.SensitiveControllerApi;
import com.usian.model.admin.dtos.SensitiveDto;
import com.usian.model.admin.pojos.AdSensitive;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(value = "敏感词管理",tags = "Sensitive", description = "敏感词管理API")
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController implements SensitiveControllerApi {

    @Autowired
    AdSensitiveService adSensitiveService;


    @Override
    @PostMapping("list")
    @ApiOperation(value = "查询敏感词信息",notes = "根据频道名称模糊查询敏感词列表")
    @ApiImplicitParam(name = "dto",type ="SensitiveDto",value = "敏感词名称")
    public ResponseResult findByNameAndPage(@RequestBody SensitiveDto dto) {
        return adSensitiveService.findByNameAndPage(dto);
    }

    @Override
    @PostMapping("save")
    @ApiOperation(value = "添加敏感词",notes = "新增敏感词信息")
    @ApiImplicitParam(name = "adSensitive",type ="AdSensitive",value = "敏感词对象")
    public ResponseResult save(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.saveSensitive(adSensitive);
    }


    @Override
    @PostMapping("update")
    @ApiOperation(value = "修改敏感词",notes = "修改感词信息")
    @ApiImplicitParam(name = "adSensitive",type ="AdSensitive",value = "敏感词对象")
    public ResponseResult updateSensitive(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.updateSensitive(adSensitive);
    }


    @Override
    @DeleteMapping("del/{id}")
    @ApiOperation(value = "删除敏感词",notes = "根据敏感词id删除频道信息")
    @ApiImplicitParam(name = "id",type ="Integer",value = "敏感词ID")
    public ResponseResult deleteById(@PathVariable Integer id) {
        return adSensitiveService.deleteById(id);
    }




}
